#include "typedefs.h"

void *memset(void *dst, int c, UINT32 n) {
  char *q = dst;
  char *end = q + n;

  for (;;) {
    if (q >= end)
      break;
    *q++ = (char)c;
    if (q >= end)
      break;
    *q++ = (char)c;
    if (q >= end)
      break;
    *q++ = (char)c;
    if (q >= end)
      break;
    *q++ = (char)c;
  }

  return dst;
}

void *memcpy(void *dest, const void *src, UINT32 n) {
  char *dp = dest;
  const char *sp = src;
  while (n--)
    *dp++ = *sp++;
  return dest;
}

SIZE strlen(const char *str) {
  SIZE i;
  for (i = 0; str[i] != '\0'; i++)
    ;
  return i;
}